home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
LOGIC Apps
/
Logic-APPLE_II_APPS.iso
/
mac
/
LOGIC Apple II 5.25" Library - DOS Part 2
/
DOS039.dsk
/
DIVISION.int
< prev
next >
Wrap
Text File
|
2012-02-16
|
3KB
|
111 lines
10 CALL -936
15 PRINT " SET INPUT LENGTH IN LINE 60":PRINT
20 PRINT " RERUN PROGRAM TO RESET #DEC PLACES"
25 PRINT :PRINT " ENTER ANY LETTER TO END":PRINT :PRINT
54 X=0
60 DIM D1$(99),D2$(99),Q(255),D2(99),D1(255),S2(99)
68 INPUT " #OF DEC.PLACES",ND
70 FOR G=1 TO 255:D1(G)=0:NEXT G
74 X=X+1:IF X#4 THEN 80
75 X= PEEK (-16384):IF X<127 THEN 75
77 CALL -936:X=1
80 INPUT " DIVIDEND?",D1$
90 INPUT " DIVISOR?",D2$
100 D1=0:D2=0
110 L1= LEN(D1$):L2= LEN(D2$)
120 FOR G=L1 TO 1 STEP -1
130 D1(G)= ASC(D1$(G,G))-176
135 IF ASC(D1$(G,G))>193 THEN END
140 IF D1(G)>-1 AND D1(G)<10 THEN NEXT G
150 IF G=0 THEN 200
160 D1=L1-G
165 L1=L1-1
170 FOR H=G TO L1+1
180 D1(H)=D1(H+1)
190 NEXT H,G
200 FOR G=L2 TO 1 STEP -1
210 D2(G)= ASC(D2$(G,G))-176
214 IF ASC(D2$(G,G))>193 THEN END
220 IF D2(G)>-1 AND D2(G)<10 THEN NEXT G
230 IF G=0 THEN 280
234 IF ASC(D2$(G,G))>193 THEN 690
240 D2=L2-G
245 L2=L2-1
250 FOR H=G TO L2
260 D2(H)=D2(H+1)
270 NEXT H,G
280 DP=L1-L2-D1+D2+2
290 L1=L2
300 FOR G=1 TO DP+ND
310 Q(G)=D1(1)/D2(1)
320 IF Q(G)>9 THEN Q(G)=9
340 C=0
350 FOR H=L1 TO 1 STEP -1
360 S2(H)=(Q(G)*D2(H)+C) MOD 10
370 IF D1(H)<10 THEN 380
375 S2(1)=Q(G)*D2(1)+C:GOTO 450
380 C=(Q(G)*D2(H)+C)/10
390 NEXT H
400 IF C=0 THEN 450
410 Q(G)=Q(G)-1
420 GOTO 340
450 FOR H=L1 TO 1 STEP -1
460 D1(H)=D1(H)-S2(H)
470 IF D1(H)>-1 THEN NEXT H
480 IF H=0 THEN 534
490 IF H=1 THEN 504
494 D1(H)=D1(H)+10
497 D1(H-1)=D1(H-1)-1
500 NEXT H
504 FOR H=L1 TO 1 STEP -1
507 D1(H)=D1(H)+S2(H)
510 IF D1(H)<10 OR H=1 THEN 520
514 D1(H)=D1(H)-10
517 D1(H-1)=D1(H-1)+1
520 NEXT H
525 Q(G)=Q(G)-1
530 GOTO 340
534 IF L1#1 THEN 540
536 D1(1)=D1(1)*10+D1(G+1)
538 GOTO 560
540 D1(2)=D1(1)*10+D1(2)
544 FOR H=1 TO L1-1
548 D1(H)=D1(H+1)
551 NEXT H
554 D1(L1)=D1(G+L1)
560 NEXT G
561 PRINT " ";
562 H=1:C=ND
564 IF DP>0 OR ND=0 THEN 610
567 PRINT ".";
570 IF DP=1 THEN 610
574 PRINT "0";
577 DP=DP+1
578 C=C-1
580 GOTO 570
610 FOR H=1 TO G-2
612 IF C=0 THEN 650
615 IF Q(1)=0 AND DP>1 AND H=1 THEN NEXT H
620 IF H#DP OR ND=0 OR C=0 THEN 640
630 PRINT ".";
640 IF H#G-2 THEN 660
650 IF Q(H+1)>4 THEN Q(H)=Q(H)+1
660 PRINT Q(H);
663 IF C=0 THEN 675
665 IF H>DP THEN C=C-1:IF C=0 THEN 650
670 NEXT H
675 PRINT :PRINT
677 IF X=3 THEN PRINT " ANY KEY TO CONTINUE"
680 GOTO 70
690 TEXT :CALL -936:VTAB 10:TAB 10:PRINT "* * * THE END * * *":END
692 REM
694 REM 'DIVISION'
699 END
65000 REM
65050 REM PROGRAM BY DUDLEY ACKERMAN
65100 REM S.F APPLE CORE- 5,15,79
65150 REM
65200 REM THIS PROGRAM GIVEN TO APPLE CORE OF SAN FRANCISCO FOR USE OF MEMBERS BY AUTHOR: DUDLEY ACKERMAN..
65250 REM JUNE 3 1979 ENTERED IN LIBRARY BY LE ROY LARSEN..
65300 REM PROGRAM CLASSIFIED - PUBLIC DOMAIN -